﻿using System.Reflection;
using System.Windows;
using System.Windows.Documents;
using System.Windows.Input;

namespace WPFMetronom
{
	/// <summary>
	/// Interaction logic for About.xaml
	/// </summary>
	public partial class About : Window
	{

		#region Declaratinos

		private string msDesigner = string.Empty;
		private string msDesignerText = string.Empty;
		private string msProgrammer = string.Empty;
		private string msProgrammerText = string.Empty;

		#endregion

		#region Constructors

		public About ( )
		{
			msDesigner = "http://vk.com/id19732466";
			msDesignerText = "Ace Ventura";
			msProgrammer = "http://vk.com/id17302829";
			msProgrammerText = "Vet";

			InitializeComponent ( );

			Run oRun = new Run ( msDesignerText );
			hlDesigner.Inlines.Clear ( );
			hlDesigner.Inlines.Add ( oRun );
			oRun = new Run ( msProgrammerText );
			hlProgrammer.Inlines.Clear ( );
			hlProgrammer.Inlines.Add ( oRun );

			hlProgrammer.TargetName = msProgrammer;
		}

		#endregion

		#region Form Events

		private void Window_Loaded ( object sender, RoutedEventArgs e )
		{
			txtVersion.Content = GetRunningVersion ( );
		}

		private void btnOk_Click ( object sender, RoutedEventArgs e )
		{
			this.Close ( );
		}

		private void txtDesigner_MouseDoubleClick ( object sender, MouseButtonEventArgs e )
		{
			System.Diagnostics.Process.Start ( msDesigner );
		}

		private void txtProgrammer_MouseDoubleClick ( object sender, MouseButtonEventArgs e )
		{
			System.Diagnostics.Process.Start ( msProgrammer );
		}

		#endregion

		#region Private Methods

		private string GetRunningVersion ( )
		{
			try
			{
				Assembly m_assembly = Assembly.GetExecutingAssembly ( );
				return m_assembly.GetName ( ).Version.ToString ( );
			}
			catch
			{
				return Assembly.GetExecutingAssembly ( ).GetName ( ).Version.ToString ( );
			}
		}

		#endregion

	}
}
